# -*- coding:utf-8 -*-
import os
import shutil
from crawler.img_tool import *

def filterFile (dir):
 list_dirs = os.walk(dir)
 for root,dirs,files in list_dirs:
         for f in files:
             imgPath = os.path.join(root,f)
             fsize = os.path.getsize(imgPath)/float(1024)
             if fsize<=50:
              shutil.move(imgPath,r"D:\TEMP\50k-")
              print imgPath+" removed"
             if fsize>50 and fsize<=100:
              shutil.move(imgPath,r"D:\TEMP\50-100k")
              print imgPath+" removed"
             if fsize>100 and fsize<=150:
              shutil.move(imgPath,r"D:\TEMP\100-150k")
              print imgPath+" removed"
             if fsize>150:
              shutil.move(imgPath,r"D:\TEMP\150k+")
              print imgPath+" removed"
if __name__ == "__main__":
 dir=r"D:\FINAL"
 toPath=r"D:\TEMP\150k+"
 #make_dir(toPath)
 filterFile(dir)

